package com.wxfbboy.suanfa.utils.algorithm;

import com.wxfbboy.suanfa.utils.algorithm.base.SortingAlgorithm;

public class InsertionSortingAlogorithm extends SortingAlgorithm {
    public static Comparable[] sort(Comparable[] a){
        int N = a.length;
        for (int i = 1; i < N ; i++){
            for (int j = i; j > 0 && less(a[j],a[j-1]); j-- ){
                exch(a,j,j-1);
            }
        }
        return a;
    }
}
